﻿<%@ Page Title="" Language="C#" MasterPageFile="~/_User.master" AutoEventWireup="true" CodeBehind="Like.aspx.cs" Inherits="WebApplication.User.Like" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
    <style>
        .body > * {
            padding: 10px;
        }
    </style>
    <%--内容--%>
    <div class="layui-row layui-col-space10 mt-10">


        <% if (artworks.Count != 0)
                { %>
            <% foreach (Models.Artworks item in artworks)
                {%>
            <div class="layui-col-md2">
                <div class="art-item">
                    <div class="cover-wrapper"
                        url="/Art/Detail.aspx?id=<%=item.ArtworkID %>"
                        style="background-image: url(<%=item.Cover.Substring(1, item.Cover.Length - 1) %>);">
                        <div class="type">
                            <a href="User/Resume.aspx?id=<%=item.OwnerID %>" target="_blank"><span class="color-money">¥ 找TA约稿 ¥</span></a>
                        </div>
                    </div>
                    <div class="flex-container user-wrapper">
                        <a style="font-size: 0px;" href="/User/Arts.aspx?id=<%=item.OwnerID %>" target="_blank">
                            <span class="avatar" style="width: 24px; height: 24px;">
                                <img src="<%=item.Owner.AvatarUrl.Substring(1, item.Owner.AvatarUrl.Length - 1) %>" />
                            </span>
                        </a>
                        <a class="nickname flex-grow-1" href="/User/Arts.aspx?id=<%=item.OwnerID %>" target="_blank"><%=item.Owner.NickName %></a>
                        <div class="like flex-shrink-0 <%=item.IsLike?"liked":"" %>" id="<%=item.ArtworkID %>">
                            <i class="iconfont icon-zan"></i>
                            <span class="count"><%=item.LikeCount %></span>
                        </div>
                    </div>
                </div>
            </div>
            <%} %>
            <script>
                $('.art-item .cover-wrapper').on('click', e => {
                    if ($(e.target).attr("url")) {
                        window.open($(e.target).attr("url"));
                    }
                })
                $('.like').on('click', e => {
                    let node = e.delegateTarget;
                    $.ajax({
                        url: '/Art/Handle.aspx',
                        method: "post",
                        data: {
                            action: "Like",
                            id: $(node).attr("id")
                        },
                        success: (msg) => {
                            location.reload();
                        }
                    })
                })
            </script>
            <%}
                else
                {%>
            <div class="empty"></div>
            <%} %>


    </div>
</asp:Content>
